home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / beveled-pattern-button.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  4.3 KB  |  135 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Beveled pattern button for web pages
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software: you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 3 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20. ; ************************************************************************
  21. ; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
  22. ; For use with GIMP 1.1.
  23. ; All calls to gimp-text-* have been converted to use the *-fontname form.
  24. ; The corresponding parameters have been replaced by an SF-FONT parameter.
  25. ; ************************************************************************
  26.  
  27. (define (text-width extents)
  28.   (car extents))
  29.  
  30. (define (text-height extents)
  31.   (cadr extents))
  32.  
  33. (define (text-ascent extents)
  34.   (caddr extents))
  35.  
  36. (define (text-descent extents)
  37.   (cadr (cddr extents)))
  38.  
  39. (define (script-fu-beveled-pattern-button
  40.          text text-size font text-color pattern pressed)
  41.   (let* (
  42.         (text-extents (gimp-text-get-extents-fontname
  43.                        text text-size PIXELS font))
  44.         (ascent (text-ascent text-extents))
  45.         (descent (text-descent text-extents))
  46.  
  47.         (xpadding 8)
  48.         (ypadding 6)
  49.  
  50.         (width (+ (* 2 xpadding)
  51.                   (text-width text-extents)))
  52.         (height (+ (* 2 ypadding)
  53.                    (+ ascent descent)))
  54.  
  55.         (img (car (gimp-image-new width height RGB)))
  56.         (background (car (gimp-layer-new img width height RGBA-IMAGE "Background" 100 NORMAL-MODE)))
  57.         (bumpmap (car (gimp-layer-new img width height RGBA-IMAGE "Bumpmap" 100 NORMAL-MODE)))
  58.         (textl (car
  59.                 (gimp-text-fontname
  60.                  img -1 0 0 text 0 TRUE text-size PIXELS font)))
  61.         )
  62.  
  63.     (gimp-context-push)
  64.  
  65.     (gimp-image-undo-disable img)
  66.     (gimp-image-add-layer img background 1)
  67.     (gimp-image-add-layer img bumpmap 1)
  68.  
  69.     ; Create pattern layer
  70.  
  71.     (gimp-context-set-background '(0 0 0))
  72.     (gimp-edit-fill background BACKGROUND-FILL)
  73.     (gimp-context-set-pattern pattern)
  74.     (gimp-edit-bucket-fill background PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
  75.  
  76.     ; Create bumpmap layer
  77.  
  78.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  79.  
  80.     (gimp-context-set-background '(127 127 127))
  81.     (gimp-rect-select img 1 1 (- width 2) (- height 2) CHANNEL-OP-REPLACE FALSE 0)
  82.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  83.  
  84.     (gimp-context-set-background '(255 255 255))
  85.     (gimp-rect-select img 2 2 (- width 4) (- height 4) CHANNEL-OP-REPLACE FALSE 0)
  86.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  87.  
  88.     (gimp-selection-none img)
  89.  
  90.     ; Bumpmap
  91.  
  92.     (plug-in-bump-map RUN-NONINTERACTIVE img background bumpmap 135 45 2 0 0 0 0 TRUE pressed 0)
  93.  
  94.     ; Color and position text
  95.  
  96.     (gimp-context-set-background text-color)
  97.     (gimp-layer-set-lock-alpha textl TRUE)
  98.     (gimp-edit-fill textl BACKGROUND-FILL)
  99.  
  100.     (gimp-layer-set-offsets textl
  101.                             xpadding
  102.                             (+ ypadding descent))
  103.  
  104.     ; Clean up
  105.  
  106.     (gimp-image-set-active-layer img background)
  107.     (gimp-image-remove-layer img bumpmap)
  108.     (gimp-image-flatten img)
  109.  
  110.     (gimp-image-undo-enable img)
  111.     (gimp-display-new img)
  112.  
  113.     (gimp-context-pop)
  114.   )
  115. )
  116.  
  117.  
  118. (script-fu-register "script-fu-beveled-pattern-button"
  119.   _"B_utton..."
  120.   _"Create a beveled pattern button for webpages"
  121.   "Federico Mena Quintero"
  122.   "Federico Mena Quintero"
  123.   "July 1997"
  124.   ""
  125.   SF-STRING     _"Text"               "Hello world!"
  126.   SF-ADJUSTMENT _"Font size (pixels)" '(32 2 1000 1 10 0 1)
  127.   SF-FONT       _"Font"               "Sans"
  128.   SF-COLOR      _"Text color"         "black"
  129.   SF-PATTERN    _"Pattern"            "Wood"
  130.   SF-TOGGLE     _"Pressed"            FALSE
  131. )
  132.  
  133. (script-fu-menu-register "script-fu-beveled-pattern-button"
  134.                          "<Image>/File/Create/Web Page Themes/Beveled Pattern")
  135.